package com.bruce.springai.service;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;

@Service
public class ChatMemoryServiceImpl implements ChatMemoryService{


    @Resource
    private ChatClient chatClient ;

    @Override
    public String chat(String memoryId, String message) {
       return  chatClient.prompt()
        .system(s -> s.param("current_date", LocalDate.now().toString()))  // 给系统提示词中的占位符{current_date}赋值     
        .user(message)
        .advisors(a -> a.param(ChatMemory.CONVERSATION_ID, memoryId)).call().content() ;

    }

}
